<?php 
/**
 * 操作
 * 
 * @version        $Id: search.php 1 8:38 2010年7月9日Z tianya $
 * @package        DedeCMS.Member
 * @copyright      Copyright (c) 2007 - 2010, DesDev, Inc.
 * @license        http://help.dedecms.com/usersguide/license.html
 * @link           http://www.dedecms.com
 */
require_once(dirname(__FILE__)."/config.php");
require_once(DEDEINC."/datalistcp.class.php");

CheckRank(0,0);
$menutype = 'mydede';
$menutype_son = 'in';
setcookie("ENV_GOBACK_URL",GetCurUrl(),time()+3600,"/");
if(!isset($dopost)) $dopost = '';

if($dopost=="closeout"){
	
	$order=$dsql->GetOne("SELECT * FROM `#@__member_operation` WHERE product='sell' and  buyid='".$buyid."' ");
	$email=$order['email'];
	
    //更新订单状态为支付余额
    $dsql->ExecuteNoneQuery("UPDATE `#@__member_operation` SET sta='3' WHERE buyid='".$buyid."'");
	
	
	$mail_title = "余款支付通知！！";
	$mail_body = "尊敬的".$order['mai1']."，您在织梦模板定制的".$order['oldinfo']."，订单号：".$order['buyid']."，".$order['mai2']."设计师已经制作完成，请及时登录会员中心支付剩余款项，超过3天未支付余款订单将被锁定，且无法退回预付款！";
	$headers = $cfg_adminemail;
	$mailtype = 'HTML';
	require_once(DEDEINC.'/mail.class.php');
	$smtp = new smtp($cfg_smtp_server,$cfg_smtp_port,true,$cfg_smtp_usermail,$cfg_smtp_password);
	$smtp->debug = false;
	$smtp->sendmail($email,$cfg_webname ,$cfg_smtp_usermail, $mail_title, $mail_body, $mailtype);
	
	ShowMsg("操作成功!","income.php",0,8);
	
	exit;
	
}
/**
 *  获取状态
 *
 * @param     string  $sta  状态ID
 * @return    string
 */
function GetSta($sta){
    if($sta==0) return '<font color=red>未完成</font>';
    else if($sta==1) return '<a href="income.php?aid=802&dopost=closeout">制作完成，我要收款</a>';
    else return '已完成';
}

if($dopost=='')
{
    $sql = "SELECT * FROM `#@__member_operation` WHERE umid='".$cfg_ml->M_ID."' and ( product='shouyi' || product='sell') and vip!=1 and money!='-0' and  money!='+0'  and sta!=0 ORDER BY aid DESC";
    $dlist = new DataListCP();
    $dlist->pageSize = 20;
    $dlist->SetTemplate(DEDEMEMBER."/templets/income.htm");    
    $dlist->SetSource($sql);
    $dlist->Display(); 
}
else if($dopost=='del')
{
    $ids = preg_replace("#[^0-9,]#", "", $ids);
    $query = "DELETE FROM `#@__member_operation` WHERE aid IN($ids) AND mid='{$cfg_ml->M_ID}'";
    $dsql->ExecuteNoneQuery($query);
    ShowMsg("成功删除指定的交易记录!","-1");
    exit();
}
